home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / TUT10.ZIP / TUT10.TXT < prev    next >
Text File  |  1994-04-05  |  11KB  |  251 lines

  1.                    ╒═══════════════════════════════╕
  2.                    │         W E L C O M E         │
  3.                    │  To the VGA Trainer Program   │ │
  4.                    │              By               │ │
  5.                    │      DENTHOR of ASPHYXIA      │ │ │
  6.                    ╘═══════════════════════════════╛ │ │
  7.                      ────────────────────────────────┘ │
  8.                        ────────────────────────────────┘
  9.  
  10.                            --==[ PART 10 ]==--
  11.  
  12.  
  13.  
  14. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  15. ■ Introduction
  16.  
  17. Wow! The trainer has finally reached part 10! This will also be the
  18. first part introduced simultaneously to local BBS's and the INTERNET at
  19. the same time! Yes folks, I put up a copy of previous tutorials onto
  20. various ftp sites, and awaited the flames saying that the net.gurus
  21. already knew this stuff, and why was I wasting disk space! The flames
  22. did not appear (well, except for one), and I got some messages saying
  23. keep it up, so from now on I will upload all future trainers to ftp
  24. sites too (wasp.eng.ufl.edu , cs.uwp.edu etc.). I will also leave a
  25. notice in the USENET groups comp.lang.pascal and comp.sys.ibm.pc.demos
  26. when a new part is finished (Until enough people say stop ;-))
  27.  
  28. I can also be reached at my new E-Mail address,
  29.                  smith9@batis.bis.und.ac.za
  30.  
  31. Well, this tutorial is on Chain-4. When asked to do a trainer on
  32. Chain-4, I felt that I would be walking on much travelled ground (I have
  33. seen numerous trainers on the subject), but the people who asked me said
  34. that they hadn't seen any, so could I do one anyway? Who am I to say no?
  35.  
  36. The sample program attached isn't that great, but I am sure that all you
  37. people out there can immediately see the potential that Chain-4 holds.
  38.  
  39.  
  40. If you would like to contact me, or the team, there are many ways you
  41. can do it : 1) Write a message to Grant Smith/Denthor/Asphyxia in private mail
  42.                   on the ASPHYXIA BBS.
  43.             2) Write to Denthor, EzE or Goth on Connectix.
  44.             3) Write to :  Grant Smith
  45.                            P.O.Box 270 Kloof
  46.                            3640
  47.                            Natal
  48.                            South Africa
  49.             4) Call me (Grant Smith) at (031) 73 2129 (leave a message if you
  50.                   call during varsity). Call +27-31-73-2129 if you call
  51.                   from outside South Africa. (It's YOUR phone bill ;-))
  52.             5) Write to smith9@batis.bis.und.ac.za in E-Mail.
  53.  
  54. NB : If you are a representative of a company or BBS, and want ASPHYXIA
  55.        to do you a demo, leave mail to me; we can discuss it.
  56. NNB : If you have done/attempted a demo, SEND IT TO ME! We are feeling
  57.         quite lonely and want to meet/help out/exchange code with other demo
  58.         groups. What do you have to lose? Leave a message here and we can work
  59.         out how to transfer it. We really want to hear from you!
  60.  
  61.  
  62.  
  63. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  64. ■ What is Chain-4?
  65.  
  66. You people out there all have at least 256k vga cards. Most of you have
  67. 512k vga cards, and some have 1MB vga cards. But what you see on your
  68. screen, as discussed in previous trainers, is 64k of data! What happened
  69. to the other 192k??? Chain-4 is a method of using all 256k at one time.
  70.  
  71. The way this is done is simple. 1 screen = 64k. 64k * 4 = 256k.
  72. Therefore, chain-4 allows you to write to four screens, while displaying
  73. one of them. You can then move around these four screens to see the data
  74. on them. Think of the Chain-4 screen as a big canvas. The viewport,
  75. the bit you see out of, is a smaller rectangle which can be anywhere
  76. over the bigger canvas.
  77.  
  78.      +----------------------------+ Chain-4 screen
  79.      |          +--+              |
  80.      |          |  | <- Viewport  |
  81.      |          +--+              |
  82.      |                            |
  83.      +----------------------------+
  84.  
  85.  
  86. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  87. ■ The size of the chain-4 screen
  88.  
  89. The Chain-4 screen, can be any size that adds up to 4 screens.
  90.  
  91. For example, it can be 4 screens across and one screen down, or one
  92. screen across and 4 screens down, or two screens across and two screens
  93. down, and any size in between.
  94.  
  95. In the sample program, the size is a constant. The size * 8 is how many
  96. pixels across there are on the chain-4 screen, ie
  97.    Size = 40   = 320 pixels across = 1 screen across, 4 screens down
  98.    Size = 80   = 640 pixels across = 2 screens across, 2 screens down
  99. etc.
  100.  
  101. We need to know the size of the screen for almost all dealings with the
  102. Chain-4 screen, for obvious reasons.
  103.  
  104.  
  105. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  106. ■ Layout of the chain-4 screen, and accessing it
  107.  
  108. If you will remember all the way back to Part 1 of this series, I
  109. explained that the memory layout of the MCGA screen is linear. Ie, the
  110. top left hand pixel was pixel zero, the one to the right of it was
  111. number one, the next one was number two etc. With Chain-4, things are
  112. very different.
  113.  
  114. Chain-4 gets the 4 screens and chains them together (hence the name :)).
  115. Each screen has a different plane value, and must be accessed
  116. differently. The reason for this is that a segment of memory is only 64k
  117. big, so that we could not fit the entire Chain-4 screen into one
  118. segment.
  119.  
  120. All Chain-4 screens are accessed from $a000, just like in MCGA mode.
  121. What we do is, before we write to the screen, find out what plane we are
  122. writing to, set that plane, then plot the pixel. Here is how we find out
  123. how far in to plot the pixel and what plane it is on :
  124.  
  125.  Instead of the linear model of MCGA mode, ie :
  126.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  127.         │00│01│02│03│04│05│06│07│08│09│10│11│ ...
  128.  
  129.  Each plane of the Chain-4 screen accesses the memory in this way :
  130.  
  131.        Plane 0 :
  132.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  133.         │00│  │  │  │01│  │  │  │02│  │  │  │ ...
  134.  
  135.        Plane 1 :
  136.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  137.         │  │00│  │  │  │01│  │  │  │02│  │  │ ...
  138.  
  139.        Plane 2 :
  140.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  141.         │  │  │00│  │  │  │01│  │  │  │02│  │ ...
  142.  
  143.        Plane 3 :
  144.         ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
  145.         │  │  │  │00│  │  │  │01│  │  │  │02│ ...
  146.  
  147. In this way, by choosing the right plane to write to, we can access all
  148. of the 256k of memory available to us. The plane that we write to can
  149. easily be found by the simple calculation of  x mod 4, and the x
  150. coordinate is also found by  x div 4. We work out our y by multiplying
  151. it by the size of our chain-4 screen.
  152.  
  153. NOTE : It is possible to write to all four planes at once by setting the
  154.        correct port values.
  155.  
  156. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  157. ■ Uses of Chain-4
  158.  
  159. The uses of Chain-4 are many. One could write data to one screen, then
  160. flip to it (the move_to command is almost instantaneous). This means
  161. that 64k of memory does not need to be set aside for a virtual screen,
  162. you are using the vga cards memory instead!
  163.  
  164. Scrolling is much easier to code for in Chain-4 mode.
  165.  
  166. It is possible to "tweak" the mode into other resolutions. In our demo,
  167. our vectors were in 320x240 mode, and our dot vectors were in 320x400
  168. mode.
  169.  
  170. The main disadvantage of chain-4 as I see it is the plane swapping,
  171. which can be slow. With a bit of clever coding however, these can be
  172. kept down to a minimum.
  173.  
  174. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  175. ■ The sample programs
  176.  
  177. The first sample program is GFX.PAS. This is a until in which I have
  178. placed most of our routines from previous tuts. All the procedures and
  179. variables you can see under the INTERFACE section can be used in any
  180. program with GFX in the USES clause. In other words, I could do this :
  181.  
  182. USES GFX,crt;
  183.  
  184. BEGIN
  185.   Setupvirtual;
  186.   cls (vaddr,0);
  187.   Shutdown;
  188. END.
  189.  
  190. This program would compile perfectly. What I suggest you do is this :
  191. Rename the file to a name that suites you (eg your group name), change
  192. the first line of the unit to that name, then add all useful procedures
  193. etc. to the unit. Make it grow :-).
  194.  
  195. The second file is the sample program (note the USES GFX,crt; up near
  196. the top!). The program is easy to understand and is documented. The bit
  197. that I want to draw your attention to is the constant, BIT. Because I
  198. am distributing this file to many places in text form, not binary form,
  199. I could not just add a .CEL file with the program. So what I did was
  200. write some text in one color then saved it as a .CEL . I then wrote a
  201. ten line program that did the following : Moving from left to right, it
  202. counted how many pixels were of color zero, then saved the byte value to
  203. an array. When it came across color one, is counted for how long that
  204. went on then saved the byte value and saved it to an array and so on.
  205. When it was finished, I converted the array into a text file in the
  206. CONST format. Not too cunning, but I thought I had better explain it ;-)
  207.  
  208. =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  209. ■ In closing
  210.  
  211. There are other documents and sample programs available on Chain-4 and
  212. it's like : Try XLIB for one...
  213.  
  214. Finally! Some BBS's have joined my BBS list! (Okay, only two new ones,
  215. but it's a start ;-)) All you international BBS's! If you will regularly
  216. download the tuts from an FTP site, give me your names!
  217.  
  218. I own a car. The car's name is Bob. A few days ago, Bob was in an
  219. accident, and now has major damage to his front. Knowing insurance, I
  220. probably won't get much, probably nothing (the other guy wasn't insured,
  221. and I am only 18 :( ). I will probably have to find work in order to pay
  222. for my repairs. The point to this meandering is this : I am upset, so if
  223. you think you are getting a quote, you can just forget it.
  224.  
  225. Oh, well. Life goes on!
  226.  
  227. See you next time,
  228.   - Denthor
  229.  
  230. These fine BBS's carry the ASPHYXIA DEMO TRAINER SERIES : (alphabetical)
  231.  
  232. ╔══════════════════════════╦════════════════╦═════╦═══╦════╦════╗
  233. ║BBS Name                  ║Telephone No.   ║Open ║Msg║File║Past║
  234. ╠══════════════════════════╬════════════════╬═════╬═══╬════╬════╣
  235. ║ASPHYXIA BBS #1           ║(031) 765-5312  ║ALL  ║ * ║ *  ║ *  ║
  236. ║ASPHYXIA BBS #2           ║(031) 765-6293  ║ALL  ║ * ║ *  ║ *  ║
  237. ║Connectix BBS             ║(031) 266-9992  ║ALL  ║   ║ *  ║ *  ║
  238. ║POP!                      ║(012) 661-1257  ║ALL  ║   ║ *  ║ *  ║
  239. ║Pure Surf BBS             ║(031) 561-5943  ║A/H  ║   ║ *  ║ *  ║
  240. ╚══════════════════════════╩════════════════╩═════╩═══╩════╩════╝
  241.  
  242. For international users : If you live outside the Republic of South
  243. Africa, do the following : Dial +27, dont dial the first 0, but dial
  244. the rest of the number. Eg, for the ASPHYXIA BBS : +27-31-765-5312
  245.  
  246. Open = Open at all times or only A/H
  247. Msg  = Available in message base
  248. File = Available in file base
  249. Past = Previous Parts available
  250.  
  251.